package com.lianzhihui.romeex.mvp.model;

import android.content.Context;

import com.lianzhihui.romeex.bean.ZZConfigBean;
import com.lianzhihui.romeex.net.APIConstant;
import com.lianzhihui.romeex.net.HttpManager;
import com.lianzhihui.romeex.net.HttpManagerCallback;
import com.lianzhihui.romeex.net.ResultData;
import com.lianzhihui.romeex.utils.GsonUtil;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.HttpParams;

/**
 * Description:
 * Author: RAMON
 * CreateDate: 2020/11/10 3:21 PM
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class ZZConfigModel {

    Context context;
    ZZConfigInterface callback;

    public ZZConfigModel(Context context, ZZConfigInterface callback) {
        this.context = context;
        this.callback = callback;
    }

    /**
     * @param coinName
     * @param coinNameCobo
     * @param type         类型 1 转账 ,2 提币
     */
    public void getConfig(String coinName, String coinNameCobo, int type) {
        HttpParams params = new HttpParams();
        params.put("type", type + "");
        params.put("coinName", coinName);
        params.put("coinNameCobo", coinNameCobo);
        new HttpManager(context, new HttpManagerCallback() {
            @Override
            public void onSuccess(ResultData o) {
                ZZConfigBean bean = GsonUtil.GsonToBean(o.getData(), ZZConfigBean.class);
                if (o.getCode() == 200) {
                    callback.onCoinSuccess(bean);
                } else {
                    callback.onCoinFail(o.getMsg());
                }
            }

            @Override
            public void onError(ApiException e) {
                callback.onCoinFail(e.getMessage());
            }
        }).post(APIConstant.COIN_CONFIG, params);
    }
}
